//
//  ViewController.swift
//  RunAPI
//
//  Created by MrSongzj on 04/14/2020.
//  Copyright (c) 2020 MrSongzj. All rights reserved.
//

import UIKit
import RunAPI

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        API.bg.weater.info(cityName: "北京市") { (response, result) in
            switch result {
            case .failure(error: let error):
                print(error.description)
                break
            case .success(data: let info):
                if let info = info {
                    print("天气：\(info.weather) 温度：\(info.temp) pm25：\(info.pm25)")
                } else {
                    print("info is nil")
                }
                break
            }
        }
        
        API.bg.weater.info(cityName: "北京市") { (_, _) in
            print("bg thread: \(Thread.current)")
        }
        API.weater.info(cityName: "北京市") { (_, _) in
            print("main thread: \(Thread.current)")
        }
        API.bg.weater.info(cityName: "北京市") { (_, _) in
            print("bg thread: \(Thread.current)")
        }
        API.weater.info(cityName: "北京市") { (_, _) in
            print("main thread: \(Thread.current)")
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

